//
//  MyCollectionFoodCell.m
//  OnionHome
//
//  Created by fengjie on 2019/9/27.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "MyCollectionFoodCell.h"

@interface MyCollectionFoodCell ()
/**<#属性#>*/
@property (nonatomic,strong)UIImageView*leftImage;
/**<#属性#>*/
@property (nonatomic,strong)UILabel*nameLabel;
/**<#属性#>*/
@property (nonatomic,strong)UILabel*contenxLabel;
/**<#属性#>*/
@property (nonatomic,strong)UILabel*numberLabel;

@end

@implementation MyCollectionFoodCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}
-(void)setModel:(PersonalHomePageModel *)model{
    _model = model;
    self.leftImage.image = IMAGE_NAMED(model.rightImage);
    self.nameLabel.text = model.title;
    self.contenxLabel.text = model.contex;
    self.numberLabel.text = [NSString stringWithFormat:@"%@人收藏",model.collectionNum] ;
}
-(void)createUI{
    [self addSubview:self.leftImage];
    [self addSubview:self.nameLabel];
    [self addSubview:self.contenxLabel];
    [self addSubview:self.numberLabel];
    
    [self.leftImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(16);
        make.bottom.mas_equalTo(-16);
        make.height.mas_equalTo(84);
        make.width.mas_equalTo(112);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.leftImage);
        make.right.mas_equalTo(-16);
    }];
    [self.contenxLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.nameLabel);
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(4);
//        make.bottom.mas_equalTo(self.numberLabel.mas_top).offset(-4);
    }];
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.nameLabel);
        make.bottom.mas_equalTo(self.leftImage);
    }];
}

-(UILabel*)nameLabel{
    if(!_nameLabel){
        _nameLabel=[UILabel new];
        _nameLabel.textColor = UIColorFromRGB(0x273323);
        _nameLabel.font = BOLDSYSTEMFONT(18);
        _nameLabel.text = @"菜品名称";
    }
    return _nameLabel;
}

-(UILabel*)contenxLabel{
    if(!_contenxLabel){
        _contenxLabel=[UILabel new];
        _contenxLabel.textColor = UIColorFromRGB(0x959E97);
        _contenxLabel.font = SYSTEMFONT(12);
        _contenxLabel.text = @"主料名称.主料名称.主料名称.主料名主料";
        _contenxLabel.numberOfLines = 2;
    }
    return _contenxLabel;
}

-(UILabel*)numberLabel{
    if(!_numberLabel){
        _numberLabel=[UILabel new];
        _numberLabel.textColor = UIColorFromRGB(0x959E97);
        _numberLabel.font = SYSTEMFONT(12);
        _numberLabel.text = @"555人收藏";
    }
    return _numberLabel;
}

-(UIImageView*)leftImage{
    if(!_leftImage){
        _leftImage=[UIImageView new];
        _leftImage.image = IMAGE_NAMED(@"dynamicDefut");
    }
    return _leftImage;
}
@end
